Skip to content

Conversation

prmukherj
Copy link
Collaborator

@prmukherj prmukherj commented Oct 3, 2025

This change updates the type-checking logic to correctly handle cases where a migration adapter is present.

Previous Behavior

When setting a textual attribute through PyFluent, type checking was performed before delegating to the underlying Settings API.
If the provided value did not strictly match the expected type, PyFluent raised a TypeError, even in cases where a migration adapter existed to handle type conversion.

For example:

>>> solver.settings.setup.models.discrete_phase.general_settings.unsteady_tracking.create_particles_at = False

Here, the property accepts a string value, but a migration adapter is available that correctly converts a boolean (False) into the appropriate string value.
Previously, PyFluent would still raise a TypeError before this conversion could occur.

Current Behavior

If a migration adapter exists for a setting, PyFluent now bypasses type checking and directly forwards the input to the Settings API.
This allows the migration adapter to handle type conversions or other logic as intended.

Please refer to the test to see the detailed usage.

The change aligns PyFluent behavior with the Fluent-side fix (ref. bug 1293534).

@github-actions github-actions bot added the bug Issue, problem or error in PyFluent label Oct 3, 2025
@seanpearsonuk
Copy link
Collaborator

The description!

Co-authored-by: Sean Pearson <93727996+seanpearsonuk@users.noreply.github.com>
@prmukherj
Copy link
Collaborator Author

The description!

Done, Thank you

@mkundu1
Copy link
Contributor

mkundu1 commented Oct 3, 2025

@prmukherj Can you please add a test?

@prmukherj
Copy link
Collaborator Author

@prmukherj Can you please add a test?

yes, sure, will add one before merging. Thank you for mentioning it.

@prmukherj prmukherj marked this pull request as draft October 3, 2025 14:02
@prmukherj prmukherj marked this pull request as ready for review October 6, 2025 08:09
@prmukherj
Copy link
Collaborator Author

@prmukherj Can you please add a test?

yes, sure, will add one before merging. Thank you for mentioning it.

@mkundu1, added the test mentioned in the fluent bug with a different case file.

@seanpearsonuk
Copy link
Collaborator

Reading the description, it’s hard to tell which parts describe the current behavior and which describe the changes introduced in this PR.

This is a wider issue for us: our PR descriptions often don’t make it easy to reconstruct what changed and why. Ideally, we should aim for descriptions that make sense even years later when reading the commit history.

At the moment, we’re falling short of that goal, and this PR is a good example of where we could do better.

@seanpearsonuk seanpearsonuk self-requested a review October 7, 2025 14:59
@prmukherj
Copy link
Collaborator Author

Reading the description, it’s hard to tell which parts describe the current behavior and which describe the changes introduced in this PR.

This is a wider issue for us: our PR descriptions often don’t make it easy to reconstruct what changed and why. Ideally, we should aim for descriptions that make sense even years later when reading the commit history.

At the moment, we’re falling short of that goal, and this PR is a good example of where we could do better.

@seanpearsonuk, could you please have a look if it is better now?

@Copilot Copilot AI review requested due to automatic review settings October 8, 2025 10:31
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a type-checking issue in PyFluent where migration adapters were being bypassed due to premature TypeError exceptions. The change allows migration adapters to handle type conversions for textual settings parameters when they are available.

  • Modified type-checking logic in set_state method to check for migration adapter presence before raising TypeError
  • Added comprehensive test coverage for the migration adapter functionality with boolean-to-string conversion scenarios
  • Updated changelog to document the fix

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/ansys/fluent/core/solver/flobject.py Modified set_state method to bypass type checking when migration adapter exists
tests/test_settings_api.py Added test cases to verify migration adapter functionality with boolean-to-string conversions
doc/changelog.d/4515.fixed.md Added changelog entry documenting the migration adapter fix

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +689 to +690
if self._has_migration_adapter:
return self.base_set_state(state=state, **kwargs)
Copy link
Preview

Copilot AI Oct 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The _has_migration_adapter property is not defined or documented in the visible code. Consider adding a comment explaining what this property represents and how it determines if a migration adapter is available.

Copilot uses AI. Check for mistakes.

@prmukherj prmukherj merged commit 4f618cb into main Oct 8, 2025
59 of 60 checks passed
@prmukherj prmukherj deleted the fix/update_migration_adapter_for_textual_settings_params branch October 8, 2025 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue, problem or error in PyFluent
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants